/**
 * Redux
 */
//1、引入redux
//2.createStore(reducer)
import {applyMiddleware, combineReducers, createStore,compose} from 'redux';
import CinemaListReducer from './reducers/CinemaListReducer';
import CityReducer from './reducers/CityReducer';
import TabbarReducer from './reducers/TabbarReducer';
import reduxThunk from 'redux-thunk'
import reduxPromise from 'redux-promise'
/**redux持久化 */
import { persistStore, persistReducer } from 'redux-persist'
import storage from 'redux-persist/lib/storage'

const persistConfig = {
    key: 'pengke',
    storage,
    whitelist:['CityReducer']   //只持久化城市的reducer
}

const reducer=combineReducers({
    CityReducer,
    TabbarReducer,
    CinemaListReducer
})
   
const persistedReducer = persistReducer(persistConfig, reducer)

const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;
const store = createStore(persistedReducer,composeEnhancers(applyMiddleware(reduxThunk,reduxPromise)))
let persistor = persistStore(store);

export{
    store,
    persistor
}